<?php


namespace Api\Controller;


class UserReportController extends BaseController {

    public function index(){
        echo 1;
        exit(1);
    }

    /**
     * 新老用户对比
     */
    public function comparisonUser(){
        $userModel = D('users');
        $todayTimestamp = strtotime("today");
        // 新用户数量
        $newUsersCount = $userModel
            ->where("reg_time > $todayTimestamp")
            ->getField("count(`user_id`) as userCount");
        $oldUsersCount = $userModel
                ->where("reg_time < $todayTimestamp")
                ->getField("count(`user_id`) as userCount");
        $this->ajaxReturn(['status'=>1,'msg'=>'success','result'=>[['name'=>'今日新增用户','value'=>$newUsersCount],['name'=>'老用户','value'=>$oldUsersCount]]]);
    }

}